package com.softserveinc.moviedbapp.application;

import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.PreferenceActivity;

import com.softserveinc.moviedbapp.R;

public class MoviePreferences extends PreferenceActivity {

	@Override
	protected void onCreate(final Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// Load the preferences from an XML resource
		addPreferencesFromResource(R.xml.preferences);

		Preference movieResutsPreference = getPreferenceScreen().findPreference("limit_movie_results");
		movieResutsPreference.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {

			@Override
			public boolean onPreferenceChange(final Preference preference, final Object newValue) {
				// TODO Auto-generated method stub
				return PreferenceInputValidator.checkNumericalInput(MoviePreferences.this, newValue,
						2, 30);
			}

		});

	}

}